MathEngine Toolkits 0.0.5 Alpha

Upgrade Notes

 

 

Overview

Dynamics Toolkit

Initializing the Memory Manager

Creating and Destroying Worlds

Creating and Destroying Objects

Enabling and Disabling Bodies and Constraints

New Joint-Limits Interface

New ContactParams Interface

Notes

Collision Toolkit

Object Initialization

Parametrization Of Geometrical Primitives

McdDtBridge and material properties

Changes in less-commonly-used API elements:

API additions

Upgrade Checklist

Notes

 

Overview

 

This document highlights the changes required to upgrade an application from MathEngine Toolkits 0.0.4 to 0.0.5.

 

Dynamics Toolkit

Initializing the Memory Manager

 

Before calling MdtWorldCreate, you must initialize the MeMemory memory manager that is used by the Toolkits for memory allocation.

The minimum requirement to initialize the memory manager is:

 

struct MeMemoryOptions opts;              

MeMemorySetDefaults(&opts);               

(*MeMemoryAPI.setOptions)(&opts);    

 

Creating and Destroying Worlds

 

Creating a world in 004 was done like this:

 

MdtWorldID world = (MdtWorld*)malloc(sizeof(MdtWorld));

MdtWorldInit(world, mem, mem_size);

 

Now you do:

 

MdtWorldID world = MdtWorldCreate(max_bodies, max_constraints, mem, mem_size);

 

When creating a world, you have to specify what the maximum number of constraints and bodies in the world is going to be. Also, the size of the memory pool that you pass in will have to be bigger than it was in the old version. MdtKea does not use more memory - it just used to use the stack where now it uses the pre-allocated pool instead.

 

Use

MdtWorldGetMaxPoolUsed(world);

 

for finding out how much of the pool you have used so far. The program will stop and an error will be given (in debug/check mode) if the memory pool is too small.

 

To get rid of an MdtWorld use:

 

MdtWorldDestroy(world);

 

This destroys all bodies or constraints you created inside that world. Their ID's are no longer valid. Do not call 'free' on an MdtWorldID.

 

Creating and Destroying Objects

 

Bodies and Constraints are now part of a world at all times. You no longer do:

 

Mdt<obj>ID thing = (Mdt<obj> *)malloc(sizeof(Mdt<obj>));

Mdt<obj>Init(thing);

 

Instead do:

 

Mdt<obj>ID thing = Mdt<obj>Create(world);

 

If you did not allocate big enough pools of bodies and constraints when you created the world, you will be given a warning (in debug/check mode).

 

To destroy a body or constraint call Mdt<obj>Destroy(). 

Do not call free on a body or constraint ID!!

 

Enabling and Disabling Bodies and Constraints

 

Now that bodies and constraints can only exist as part of a world, there is no need to 'attach' them to a world. As a result, all Attach and Detach functions have been removed. For constraints, use Enable and Disable as you would have used Attach and Detach before - they simply add that constraint into the set of active constraints in the world. For bodies, use Enable and Disable as Wake and Kill were used before. There was no need to have 'detached' bodies in a world, as 'attached' but 'killed' bodies used almost no processing power anyway.

 

To reflect this, the DEMModes have been renamed to MdtDEMModeNoPartition, MdtDEMModePartitionAutoDisable and MdtDEMModePartitionNoAutoDisable. Bodies are now no longer 'auto-enabled' when you change their position, apply a force, etc. This puts more responsibility on the toolkit user. The default mode has been changed from AutoDisable to NoAutoDisable. This means toolkit users have to consciously turn on this feature.

 

New Joint-Limits Interface

 

Currently for Hinges and Prismatics, we have a new joint limit system. For these joint-types you can use Mdt<obj>GetLimit, which returns an MdtLimitID. You can then use the MdtLimit functions to modify it. Each MdtLimitID has two MdtSingleLimitID's (one for the top limit and one for the bottom limit). Each limit can have a position (angle etc.), stiffness, damping and restitution etc. The MdtLimitID lets you set a motor, or a spring, or a limit, or some combination. See the Hinge or Prismatic demo for an example of this. A spring or motor done in this way is very stable.

 

New ContactParams Interface

 

In a similar style there is a separate interface for Contact and ContactParams. You can either use MdtContactGetParams() or McdDtBridgeGetContactParams() to get an MdtContactParamsID. Then you can use the MdtContactParams functions to set properties like Friction, Restitution etc. There is also a function, MdtContactParamsSetFriction(), which sets both Primary and Secondary friction simultaneously.

 

Notes

 

Collision Toolkit

Object Initialization

In previous release, types and interactions were loaded implicitly by including the appropriate header files in the translation unit in which McdInit() is invoked. Now this has been replaced by explicit function calls:

 

change in function signature:

 

McdInit(); --> McdInit( int geoTypeMaxCount );

 

new functions, such as:

 

McdPrimitivesRegisterTypes();

McdPrimitivesRegisterInteractions();

 

 ( see "API additions" for complete list )

 

Parametrization Of Geometrical Primitives

 

Box uses dimensions instead of radii

McdBoxCreate( MeReal r1, MeReal r2, MeReal r3 );

--> McdBoxCreate( MeReal d1, MeReal d2, MeReal d3 );

 

McdCylinderCreate( MeReal radius, MeReal halfHeight );

--> McdCylinderCreate( MeReal radius, MeReal height );

 

type McdZPlane renamed to type McdPlane.

 

McdDtBridge and material properties

McdDtBridge initializer now takes an argument:

McdDtBridgeInit(); -->

McdDtBridgeInit( materialIDMaxCount );

 

Name change for setting relative transform:

McdDtBridgeSetRelativeTransformPtr() -->

McdDtBridgeSetRelativeTransformPtrToBody()

 

Material properties are now set via:

McdDtBridgeGetDefaultMaterialID();

McdDtBridgeGetNewMaterialID();

McdDtBridgeGetMaterialIDMaxCount();

 

Changes in less-commonly-used API elements:

Direct intersection tests for individual McdModel pairs now performed via:

McdIntersectHello();

McdIntersect();

McdIntersectGoodbye();

 

Change in access of nearby pairs in McdSpace:

 

Originally using

McdSpaceGetNewPairs();

McdSpaceGetNearbyPairs();

McdSpaceGetOldPairs();

 

Now using

McdSpaceGetHelloPairs();

McdSpaceGetStayingPairs();

McdSpaceGetGoodbyePair();

 

and signatures now rely on an explicit pair iterator obtained from:

McdSpaceGetHelloPairIterator();

McdSpaceGetStayingPairIterator();

McdSpaceGetGoodbyePairIterator();

 

various functions renamed:

McdDtBridgeUpdateCompound() --> McdDtBridgeUpdateModelTransfromFromBody()

McdSpaceGetLineSegmentOverlapList() --> McdSpaceGetLineSegIntersections()

McdModelGetLineSegmentOverlapInfo() -->  McdLineSegIntersect()

McdDispatcherSetContactPointMaxCount() -> McdIntersectSetContactBufferSize()

McdDispatcherGetContactPointMaxCount() -> McdIntersectGetContactBufferSize()

McdDispatcherSetMaxContactCount() -> McdIntersectRequestSetContactMaxCount()

McdDispatcherGetMaxContactCount() -> McdIntersectRequestGetContactMaxCount()

 

various structs renamed

McdSpacePair --> McdModelPair

McdInteractionResult --> McdIntersectResult

McdInteractionLSResult --> McdLineSegIntersectResult

 

API additions

 

new types

McdConvexMesh  (see McdConvexMesh.h )

McdRGHeightField  (see McdRGHeightField.h )

 

Registration calls

McdPrimitivesGetTypeCount();

McdPrimitivesRegisterTypes();

McdPrimitivesRegisterInteractions();

McdSphereBoxPlaneRegisterTypes();

McdSphereBoxPlaneRegisterInteractions();

 

mass property computation for most geometry types

McdGeometryGetMassProperties();

 

simplification/reduction of results from contact generation

McdContactSimplify();

 

McdDtBridge utility

McdDtBridgeUpdateBodyTransfromFromModel()

 

Upgrade Checklist

 

004 Version

005 Version

 

 

APPEND_F

(MeReal)

LibMdtConstraints.a

LibMdtBcl.a

MdtWorld

MdtWorldInit

MdtWorldID

MdtWorldCreate

Mdt<obj>

Mdt<obj>Init

Mdt<obj>Attach

Where <obj> refers to: Body and all constraints (contacts and joints).

e.g.

MdtBody

MdtBodyInit

MdtBodyAttach

Mdt<obj>ID

Mdt<obj>Create

Mdt<obj>Enable

 

 

e.g.

MdtBodyID

MdtBodyCreate

MdtBodyEnable

MdtBodyGetTM

MdtBodyGetTransformPtr

Mdt<obj>SetBodies

Not Required, set in create function

MdtCon...

MdtBcl...

MdtConContactOptionSlippy

MdtBclContactOptionSlip

MdtConContactOptionSlidey

MdtBclContactOptionSlide

libMcd.a

libMcdFrame.a

libMcdPrimitives.a

Mcd.lib

McdFrame.lib

McdPrimitives.lib

#include "McdCore.h"

#include "McdFrame.h"

#include "McdPrimitives.h"

McdInit.h

No longer required.

McdInit()

McdInit(number_of_primitives)

McdInteractionResult

McdIntersectResult

McdModelSetMaterialID

McdDtBridgeSetMaterialID

McdBridgeInit()

McdBridgeInit(number_of_primitives)

McdDtBridgeCreate(##)

McdDtBridgeCreate()

McdDtBridgeSetRelativeTransformPtr

McdDtBridgeSetRelativeTransformToBodyPtr

McdGetDefaultMaterialID

McdDtBridgeGetDefaultMaterialID

McdDispatcherGetDefaultRequestID

McdIntersectGetDefaultRequestID

McdDispatcherSetFaceNormalsFirst

McdIntersectSetFaceNormalsFirst

Separation [McdContact structure]

Penetration [McdContact structure]

McdBoxCreate( MeReal r1, MeReal r2, MeReal r3 );

McdBoxCreate( MeReal d1, MeReal d2, MeReal d3 );

uses dimensions instead of radii

McdCylinderCreate( MeReal radius, MeReal halfHeight );

McdCylinderCreate( MeReal radius, MeReal height );

 

McdZPlane

McdPlane

McdBoxCreate( MeReal r1, MeReal r2, MeReal r3 );

McdBoxCreate( MeReal d1, MeReal d2, MeReal d3 );

uses dimensions instead of radii

 

 

Notes